package com.mate.cloud.redisson.controller;


import com.mate.cloud.common.web.controller.AdminBaseController;
import com.mate.cloud.redisson.service.ProductTagService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

/**
 * @description:    java类作用描述
 * @author:         MI
 * @email:          448341911@qq.com
 * @createTime:     2025/8/23 19:43
 * @updateUser:     MI
 * @updateTime:     2025/8/23 19:43
 * @updateRemark:   修改内容
 * @version:        1.0
 */
@RestController
@RequestMapping("/product/tags")
@RequiredArgsConstructor
public class ProductTagController extends AdminBaseController {

    private final ProductTagService service;

    @PostMapping("/add")
    public String addTag(@RequestParam String productId, @RequestParam String tagId) {
        service.addTag(productId, tagId);
        return "标签添加成功";
    }

    @PostMapping("/remove")
    public String removeTag(@RequestParam String productId, @RequestParam String tagId) {
        service.removeTag(productId, tagId);
        return "标签移除成功";
    }

    @GetMapping("/product/{productId}")
    public Set<String> getTagsByProduct(@PathVariable String productId) {
        return service.getTagsByProduct(productId);
    }

    @GetMapping("/tag/{tagId}")
    public Set<String> getProductsByTag(@PathVariable String tagId) {
        return service.getProductsByTag(tagId);
    }

    @GetMapping("/search")
    public Set<String> getProductsByTags(@RequestParam Set<String> tagIds) {
        return service.getProductsByTags(tagIds);
    }
}
